//算法设计课程 第一次OJ first and last position search
#include <iostream>
#include <string.h>

void binary_search(int arr[], int n, int target, int res[])
{
    if (n == 0)
    {
        res[0] = -1;
        res[1] = -1;
    }
    int l = 0, r = n - 1;
    // 第一次二分查找，查找开始的位置
    while (l < r)
    {
        int mid = (l + r) / 2;
        
        if (arr[mid] >= target)
            //往左查找
            r = mid;
        else
            //往左查找
            l = mid + 1;
    }
    if (arr[r] != target)
    {
        res[0] = -1;
        res[1] = -1;
        return ;
    }
    res[0] = r;
    l = 0;
    r = n - 1;
    //第二次二分查找，找到数字结束的位置
    while (l < r)
    {
        int mid = (l + r + 1) / 2;
        if (arr[mid] <= target)
            //往右移动
            l = mid;
        else 
            r = mid - 1;
    }
    res[1] = r;
}
int main()
{
    using namespace std;
    int n, m;
    cin >> n;
    cin >> m;
    int arr[n];
    int targets[m];
    memset(arr, 0, sizeof(arr));
    memset(targets, 0, sizeof(targets));

    for (int i = 0; i < n; i++)
        cin >> arr[i];
    for (int i = 0; i < m; i++)
        cin >> targets[i];

    int res[2];

    for (int i = 0; i < m; i++)
    {
        binary_search(arr, n, targets[i], res);
        cout << res[0] << " " << res[1] << endl;
    }
    return 0;
}